/**
 * @description  净值分析
 * @author shenhong
 */
import React, { PureComponent } from 'react';
import { connect } from 'dva';
import { XYAxisChartsC } from '../../../components';
import _ from 'lodash';

class showEchartsOne extends PureComponent {
  constructor() {
    super();
    this.state = {};
  }

  componentDidMount() {}

  getMaxAndMinNum = (arr1, ar2) => {
    const max1 = _.max(arr1);
    const max2 = _.max(ar2);
    const min1 = _.min(arr1);
    const min2 = _.min(ar2);
    const newArr =
      [
        [max1, min1],
        [max2, min2],
      ] || [];
    return newArr;
  };

  // 展示收益趋势图
  showEcharts = () => {
    const {
      netValueM: { echartsData1 },
      loading,
    } = this.props;
    const { xAxis } = echartsData1;
    const { series } = echartsData1;
    const data = series && series.length ? this.getMaxAndMinNum(series[0].data, series[1].data) : [];
    return (
      <div>
        <XYAxisChartsC
          dataZoom={true}
          yAxisUnit={[' ', '单位（%）']}
          series={series}
          xAxis={xAxis}
          height={258}
          type='line'
          yAxisRange={data}
          loading={loading}
          gridLeft={70}
          gridRight={70}
        />
      </div>
    );
  };

  render() {
    return <div>{this.showEcharts()}</div>;
  }
}
export default connect(({ netValueM }) => ({
  netValueM,
}))(showEchartsOne);
